OUTDIR = build
TARGET = $(OUTDIR)/main

# GOARCH 设置为 arm64，GOOS 设置为 linux，确保编译为 ARM64 架构的 Linux 可执行文件
GOARCH = arm64
GOOS = linux

# 使用 Go 编译 main.go 文件
main: main.go key.go flow.go cron_reboot.go
	mkdir -p $(OUTDIR)
	sudo GOARCH=$(GOARCH) GOOS=$(GOOS) go build -ldflags="-s -w" -o $(TARGET) main.go key.go flow.go upload.go cron_reboot.go
	/home/czh/Downloads/upx2 $(TARGET)

# make strip
strip:
	aarch64-linux-gnu-strip $(TARGET)

# make clean
clean:
	rm -rf $(OUTDIR)

# make clean
upx:
	/home/czh/Downloads/upx2 $(TARGET)


# make push，用于提交并推送代码到 Git 仓库，使用 sudo 权限
push:
	sudo git add .
	sudo git commit -m "Automated commit from Makefile"
	sudo git push

.PHONY: clean strip push